import inspect

def generator():
    i='activate'
    while True:
        try:
            value=yield i
        except ValueError:
            print('over')
        i=value

g=generator()
print(inspect.getgeneratorstate(g))
print(next(g))
print(inspect.getgeneratorstate(g))
print(g.send('hello'))
g.throw(ValueError)
g.close()
print(inspect.getgeneratorstate(g))
